package com.zc.web.service.impl;


import com.zc.common.utils.DateUtils;
import com.zc.web.domain.TimeRecord;
import com.zc.web.mapper.TimeRecordMapper;
import com.zc.web.service.ITimeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;




import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Arrays;
import java.util.List;

/**
 * 时间账本Service业务层处理
 *
 * @author zc
 * @date 2025-10-21
 */
@Service
public class TimeRecordServiceImpl extends ServiceImpl<TimeRecordMapper, TimeRecord> implements ITimeRecordService
{
    @Autowired
    private TimeRecordMapper timeRecordMapper;

    /**
     * 查询时间账本
     *
     * @param id 时间账本主键
     * @return 时间账本
     */
    @Override
    public TimeRecord selectTimeRecordById(Long id)
    {
                return getById(id);
    }

    /**
     * 查询时间账本列表
     *
     * @param timeRecord 时间账本
     * @return 时间账本
     */
    @Override
    public List<TimeRecord> selectTimeRecordList(TimeRecord timeRecord)
    {
        return timeRecordMapper.selectTimeRecordList(timeRecord);
    }

    /**
     * 新增时间账本
     *
     * @param timeRecord 时间账本
     * @return 结果
     */
    @Override
    public int insertTimeRecord(TimeRecord timeRecord)
    {

                timeRecord.setCreateTime(DateUtils.getNowDate());
                        return save(timeRecord) == true? 1 : 0;
    }

    /**
     * 修改时间账本
     *
     * @param timeRecord 时间账本
     * @return 结果
     */
    @Override
    public int updateTimeRecord(TimeRecord timeRecord)
    {

                timeRecord.setUpdateTime(DateUtils.getNowDate());
                return updateById(timeRecord) == true ? 1 : 0;
    }

    /**
     * 批量删除时间账本
     *
     * @param ids 需要删除的时间账本主键
     * @return 结果
     */
    @Override
    public int deleteTimeRecordByIds(Long[] ids)
    {
                return removeByIds(Arrays.asList(ids)) == true ? 1 : 0;
    }

    /**
     * 删除时间账本信息
     *
     * @param id 时间账本主键
     * @return 结果
     */
    @Override
    public int deleteTimeRecordById(Long id)
    {
                return removeById(id) == true ? 1 : 0;
    }
}